<template>
  <view class="container">
    <view class="header">📚 技术资料</view>

    <scroll-view scroll-y class="doc-list">
      <view
        class="doc-item"
        v-for="(item, index) in docList"
        :key="index"
        @click="goToPreview(item)"
      >
        <image :src="item.icon" class="doc-icon" />
        <view class="doc-info">
          <view class="doc-title">{{ item.title }}</view>
          <view class="doc-meta">
            <text class="type">{{ item.type }}</text>
            <text class="time">{{ item.date }}</text>
          </view>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      docList: [
        {
          title: "电梯月度维保规范手册",
          type: "PDF文档",
          date: "2025-07-15",
          icon: "/static/pdf_icon.png",
          url: "/static/docs/maintain.pdf"
        },
        {
          title: "故障代码查询表（通用型）",
          type: "Excel表格",
          date: "2025-06-30",
          icon: "/static/excel_icon.png",
          url: "/static/docs/errors.xlsx"
        },
        {
          title: "1号楼电梯布线图",
          type: "图片图纸",
          date: "2025-07-10",
          icon: "/static/image_icon.png",
          url: "/static/docs/wiring.jpg"
        }
      ]
    };
  },
  methods: {
    goToPreview(item) {
      uni.showToast({
        title: '模拟打开文档',
        icon: 'none'
      });

      // 实际使用中可跳转至：PDF预览 / 图片预览 / 富文本页面
      // uni.navigateTo({
      //   url: '/pages/docs/preview?url=' + encodeURIComponent(item.url)
      // });
    }
  }
};
</script>

<style scoped>
.container {
  padding: 30rpx;
  background-color: #f8f8f8;
  min-height: 100vh;
}

.header {
  font-size: 40rpx;
  font-weight: bold;
  text-align: center;
  margin-bottom: 30rpx;
}

.doc-list {
  max-height: calc(100vh - 120rpx);
}

.doc-item {
  display: flex;
  background-color: #ffffff;
  border-radius: 16rpx;
  padding: 20rpx;
  margin-bottom: 20rpx;
  align-items: center;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
}

.doc-icon {
  width: 80rpx;
  height: 80rpx;
  margin-right: 20rpx;
}

.doc-info {
  flex: 1;
}

.doc-title {
  font-size: 32rpx;
  font-weight: 600;
  margin-bottom: 8rpx;
  color: #333;
}

.doc-meta {
  font-size: 26rpx;
  color: #999;
  display: flex;
  justify-content: space-between;
}
</style>
